package org.jeik;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import org.jeik.data.models.Service;


@FacesConverter(forClass=Service.class,value="ServiceConverter")
public class ServiceConverter implements Converter {
	
	/**
	 * 
	 * @param context
	 * @param component
	 * @param value
	 * @return
	 */
	public String getAsString(FacesContext context, UIComponent component, Object value) {
		return value.toString();
	}
	
	/**
	 * 
	 * @param arg0
	 * @param arg1
	 * @param value
	 * @return
	 */
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String value) {

      Service service = new Service();
      service.setId(Long.parseLong(value));   
      return service;
   }
	
}
